{extend name="public:layout" /}

{block name="title"}
    <title>{:site('siteName')}-充值审核</title>
{/block}

{block name="css"}
    <style>
        .layui-btn{    height: 25px;line-height: 25px;    padding: 0 3px;}
        .layui-form-item .layui-input-inline{    margin: 0 0 10px 0px;}
        .lh p{ height: 41px; }
    </style>
{/block}

{block name="content"}
    <div class="head">充值审核</div>
    <div class="account_li lh">
        <ul>
            {volist name="list" id="v"}
            <li>
                <p><span>会员ID</span><br />{$v.user_id}</p>
                <p><span>用户名</span><br />{$v.username}</p>
                <p><span>充值数量</span><br />{$v.num}</p>
                <p><span>说明</span> <br />{$v.explain}</p>
                <p><span>状态</span><br />
                    {eq name="v.status" value="-1"}充值失败{/eq}
                    {eq name="v.status" value="0"}待支付{/eq}
                    {eq name="v.status" value="1"}已支付{/eq}
                    {eq name="v.status" value="2"}充值成功{/eq}
                </p>
                <p><span>创建时间</span><br />{:date('m-d H:i',$v['create_time'])}</p>
                <p>
                    <span>操作</span><br />
                    {if $v['status'] == 0 || $v['status'] == 1}
                        <button data-rid="{$v.id}" class="layui-btn layui-btn-mini layui-btn-main confirm-success">成功</button>
                        <button data-rid="{$v.id}" class="layui-btn layui-btn-mini layui-btn-danger confirm-fail">失败</button>
                    {/if}
                </p>
            </li>
            {/volist}
        </ul>
    </div>
    <div class="page">
        {$list->render()}
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        layui.use(['form', 'layer'], function(){
            var $ = layui.jquery;
            var layer = layui.layer;

            $(".confirm-success").click(function() {
                var rid = $(this).data('rid');
                layer.confirm('审核成功，{$currency}即时到账，确认。', {
                    btn: ['确认', '取消'],
                    icon: 3
                }, function(index) {
                    $.post('{:url("index/agent/confirm")}', {id: rid,status:'2'}, function(res) {
                        if(res.status == 1){
                            layer.msg(res.msg, {
                                time: 1000
                            }, function() {
                                location.reload();
                            });
                        }else{
                            layer.msg(res.msg);
                        }
                    },'json');
                    layer.close(index);
                });
                return false;
            });

            $(".confirm-fail").click(function() {
                var rid = $(this).data('rid');
                layer.prompt({
                    title: '请输入失败原因',
                }, function(value, index, elem){
                    $.post('{:url("index/agent/confirm")}', {id: rid,status:'-1',explain:value}, function(res) {
                        if(res.status == 1){
                            layer.msg(res.msg, {
                                time: 1000
                            }, function() {
                                location.reload();
                            });
                        }else{
                            layer.msg(res.msg);
                        }
                    },'json');
                    layer.close(index);
                });
                return false;
            });

        });
    </script>
{/block}